import nt from './network'
import Vue from 'vue'
import session from './session'

export default {
    datas: {
        // 'dict': [
        //     { dict_code: "REAL_TIME_JOB", dict_name: "实时任务", p_code: "taskType" },
        //     { dict_code: "TRIGGER_TIME_JOB", dict_name: "定时任务", p_code: "taskType" },
        //     { dict_code: "CRON_JOB", dict_name: "Cron任务", p_code: "taskType" },
        //     { dict_code: "REPEAT_JOB", dict_name: "Repeat任务", p_code: "taskType" },
        // ]
    },
    dataUris: {
        'resourceItem': '/v1/resourceItem?q=eyJyZXNvdXJjZVR5cGUiOiJDT01QVVRJTkcifQ%3D%3D&p=eyJwYWdlU2l6ZSI6MTAwMCwiY3VycmVudFBhZ2UiOjF9',
        'dict': '/message/messageplatform/common/v1/glbDict/getAll',
        'menus': '/message/messageplatform/v1/menu/list',
        'obj': '/message/messageplatform/v1/sysObj/list'
    },
    dataList: null,
    async getData(name, item, key, callback) {
        if (!this.datas[name]) {
            var resp = await nt.request('get', this.dataUris[name]);
            this.datas[name] = await resp.data;
        }
        if (item && key) {
            Vue.set(item, key, JSON.parse(JSON.stringify(this.datas[name])));
        }
        if (callback && typeof(callback) == 'function') {
            callback(JSON.parse(JSON.stringify(this.datas[name])));
        }
        return;

    },

}